home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 September / macformat-004.iso / Shareware City / Sound / Movie2Snd Folder / Read Me < prev   
Encoding:
Text File  |  1994-06-11  |  4.7 KB  |  289 lines  |  [ttro/ttxt]

  1. Movie2Snd is a very simple application which extracts soundtracks from
  2. QuickTime movies.
  3.  
  4. Drop-launch a movie onto the application (or choose a movie from the open dialog).
  5. You will be prompted for a location for the resulting sound file.  That sound
  6. file is a plain ol' System 7 sound file that can be played by opening
  7. (double clicking).
  8.  
  9. To extract a sound from a CD:
  10. • Choose the CD from the open dialog and select the track you want.
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. • A save dialog will appear asking you for a save location for the intermediate movie.  Switch back to your hard drive.
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. • Use the options button to select the sample you want.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. • The audio will be converted to a QuickTime movie
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. • A second save dialog will appear, prompting you for the location to save the sound file.
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. • You can the temporary QuickTime movie after the conversions are done.  
  94.  
  95. Version 1.1 adds better error reporting and uses so-called MultiFinder memory, so it doesn't need a large memory partition.  Note that large movies still require large amounts of memory.  Check the "Largest Unused Block" under "About this Macintosh" in the Finder.
  96.  
  97. -- Scott Lindsey <wombat@claris.com>
  98.  
  99. Movie2Snd is neither a product of nor is supported by Claris Corporation.
  100. This program is freely distributable.  Here's the source:
  101.  
  102. // (No, this isn't very good example-ware.  It's just a quick hack.)
  103.  
  104. #include <Aliases.h>
  105. #include <Folders.h>
  106. #include <Movies.h>
  107. #include <Sound.h>
  108. #include <ImageCompression.h>
  109.  
  110. void MakeSnd(FSSpec *);
  111. void Message(OSErr, Boolean);
  112.  
  113. Boolean tempMemory;
  114.  
  115. void main(void)
  116. {
  117.     long    response;
  118.     short     Action, Count;
  119.     OSErr    err;
  120.     AppFile    File;
  121.     FSSpec    fs;
  122.     SFTypeList types = {'MooV'};
  123.  
  124.     if (!Gestalt(gestaltOSAttr, &response) && (response & 1L<<gestaltRealTempMemory))
  125.         tempMemory = true;
  126.  
  127.     MaxApplZone();    
  128.     InitGraf(&qd.thePort);
  129.     InitFonts();
  130.     InitWindows();
  131.     InitMenus();
  132.     TEInit();
  133.     InitDialogs(0L);
  134.     InitCursor();
  135.  
  136.     err = Gestalt(gestaltQuickTime, &response);
  137.     Message(err, true);
  138.  
  139.     EnterMovies();
  140.  
  141.     CountAppFiles(&Action, &Count);
  142.     if (Action == appPrint)
  143.         ExitToShell();
  144.  
  145.     if (Count)
  146.     {
  147.         GetAppFiles(Count, &File);
  148.         FSMakeFSSpec(File.vRefNum, 0L, File.fName, &fs);
  149.     }
  150.     else
  151.     {
  152.         StandardFileReply reply;
  153.         
  154.         StandardGetFilePreview(0L, 1, types, &reply);
  155.         if (!reply.sfGood)
  156.             ExitToShell();
  157.         fs = reply.sfFile;
  158.         Count = 1;
  159.     }
  160.  
  161.     for (;;)
  162.     {
  163.         MakeSnd(&fs);
  164.         if (!--Count)
  165.             break;
  166.         GetAppFiles(Count, &File);
  167.         FSMakeFSSpec(File.vRefNum, 0L, File.fName, &fs);
  168.     }
  169.  
  170.     ExitToShell();
  171. }
  172.  
  173. void MakeSnd(FSSpec *fs)
  174. {
  175.     short refNum, resID = 0;
  176.     Movie movie;
  177.     OSErr err;
  178.     StandardFileReply reply;
  179.     Handle h;
  180.     Size size;
  181.     
  182.     err = OpenMovieFile(fs, &refNum, fsRdPerm);
  183.     Message(err, true);
  184.  
  185.     err = NewMovieFromFile(&movie, refNum, &resID, nil, newMovieActive, nil);
  186.     Message(err, true);
  187.  
  188.     err = CloseMovieFile(refNum);
  189.     // Don't bother with errors here.  Unimportant
  190.     
  191.     StandardPutFile("\pSave Sound as:", "\pA Sound", &reply);
  192.     
  193.     if (!reply.sfGood)
  194.         return;
  195.  
  196.     if (reply.sfReplacing)
  197.     {
  198.         err = FSpDelete(&reply.sfFile);
  199.         Message(err, true);
  200.     }
  201.  
  202. #ifdef AIFF
  203.     err = ConvertMovieToFile(movie, 0, &reply.sfFile, 'AIFF', '????', smCurrentScript, nil, 0, 0);
  204.  
  205. #else
  206.  
  207. #if 0    // "Correct" way to do this, but no handler exists for this conversion...
  208.     err = ConvertMovieToFile(movie, 0, &reply.sfFile, 'sfil', 'movr', smCurrentScript, nil, 0, 0);
  209. #else
  210.      FSpCreateResFile(&reply.sfFile, 'movr', 'sfil', -1);
  211.      Message(ResError(), true);
  212.  
  213.     refNum = FSpOpenResFile(&reply.sfFile, fsWrPerm);
  214.     Message(ResError(), true);
  215.  
  216.     if (tempMemory)
  217.     {
  218.         if (TempMaxMem(nil) > MaxBlock())
  219.         {
  220.             h = TempNewHandle(1024, &err);
  221.         }
  222.         else
  223.             h = NewHandle(1024);
  224.     }
  225.     else
  226.         h = NewHandle(1024);
  227.  
  228.     if (MemError())
  229.     {
  230.         Message(MemError(), false);
  231.         err = -1;
  232.         goto exit;
  233.     }
  234.  
  235.     if (!h)
  236.         goto exit;
  237.  
  238.     SetZone(HandleZone(h));
  239.     err = PutMovieIntoTypedHandle(movie, 0, 'snd ', h, 0, GetMovieDuration(movie), 0, 0);
  240.     SetZone(ApplicationZone());
  241.     Message(err, false);
  242.     if (!err)
  243.         AddResource(h, 'snd ', 128, reply.sfFile.name);
  244. exit:
  245.     CloseResFile(refNum);
  246. #endif
  247. #endif    // 
  248.     if (err)
  249.         FSpDelete(&reply.sfFile);
  250. }
  251.  
  252. void Message(OSErr err, Boolean fatal)
  253. {
  254.     Str255 str;
  255.     StringPtr s;
  256.     
  257.     if (!err)
  258.         return;
  259.     
  260.     ParamText("\p", "\p", "\p", "\p");
  261.     
  262.     switch(err)
  263.     {
  264.         case ioErr:
  265.             s = "\pAn I/O error occurred.";
  266.             break;
  267.         case fnfErr:
  268.             s = "\pThe file could not be found.";
  269.             break;
  270.         case memFullErr:
  271.             s = "\pThere is not enough memory for this operation.";
  272.             break;
  273.         case gestaltUnknownErr:
  274.         case gestaltUndefSelectorErr:
  275.             s = "\pQuickTime is required to run this application.";
  276.             break;
  277.         default:
  278.             NumToString(err, str);
  279.             s = "\pUnexpected error: ^1.";
  280.             ParamText(nil, str, nil, nil);
  281.             break;
  282.     }
  283.     ParamText(s, nil, nil, nil);
  284.     StopAlert(128, nil);
  285.  
  286.     if (fatal)
  287.         ExitToShell();
  288. }
  289.